import pandas as pd
import os

# 处理3D数据文件
def process_3d_data():
    current_dir = os.path.dirname(os.path.abspath(__file__))
    input_file = os.path.join(current_dir, "3d_asc.csv")
    output_file = os.path.join(current_dir, "fc3d_history.csv")
    
    # 读取数据文件
    df = pd.read_csv(input_file, encoding='gbk')
    
    # 重命名列
    df = df.rename(columns={
        '开奖期号': 'draw_issue',
        '开奖日期': 'draw_date',
        '1号': 'num_1',
        '2号': 'num_2',
        '3号': 'num_3'
    })
    
    # 保存处理后的数据
    df.to_csv(output_file, encoding='utf-8', index=False)
    print(f"3D数据已处理并保存到: {output_file}")
    print(f"数据条数: {len(df)}")

if __name__ == "__main__":
    process_3d_data()